<?php

class dcDeployTask extends sfBaseTask
{
  protected function configure()
  {
    // // add your own arguments here
    // $this->addArguments(array(
    //   new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED, 'My argument'),
    // ));

    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
      // add your own options here
    ));

    $this->namespace        = 'oceba';
    $this->name             = 'deploy';
    $this->briefDescription = '';
    $this->detailedDescription = <<<EOF
The [dc:deploy|INFO] task does things.
Call it with:

  [php symfony dc:deploy|INFO]
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();

    // add your code here
    $uri_message_backend = sfConfig::get('sf_root_dir') . '/apps/backend/i18n/es/messages.xml';
    $uri_message_frontend = sfConfig::get('sf_root_dir') . '/apps/frontend/i18n/es/messages.xml';

    $this->runTask('cache:clear');
    $this->runTask('propel:build',array('args1'=>'--all-classes'));
    $this->runTask('project:permissions');
    $this->runTask('plugin:publish-assets');
    $this->runTask('cache:clear');


  }
}
